#include <REGX52.H>
#include <INTRINS.h>
#include "Timer0.h"
#include "Key.h"
#include <INTRINS.H>//函数库


unsigned char KeyNum,LEDMode;
void main()
{
	  P2=0xFE;
 	  Timer0Init();
		while(1)
		{
				KeyNum = Key();
				if(KeyNum)
				{
					if(KeyNum==1)LEDMode=0;
					if(KeyNum==2)LEDMode=1;
////					{
////						LEDMode++;
////						if(LEDMode>=2)LEDMode=0;
////						
////					}
				}	
		}
}

//中断函数 + 小尾巴
void Timer0_Routine() interrupt 1
		{
				static unsigned int T0Count;
				TL0 = 0x18;
				TH0 = 0xFC;//每次进入中断函数赋初始值
				T0Count++;
				if(T0Count>=100)
		{
        T0Count=0;//清零
				if(LEDMode==0)P2=_crol_(P2,1);
				if(LEDMode==1)P2=_cror_(P2,1);
					
		  }
	}